package algorithm.leetcode.I401to600;

public class Q461 {

    public int hammingDistance(int x, int y) {
        // x是较大的那个
        x = x ^ y;
        int k = 0;
        while (x != 0) {
            if ((x&1) == 1) k++;
            x = x >> 1;
        }
        return k;

    }

    public static int countOne(int x) {
        // x是较大的那个
        int k = 0;
        while (x != 0) {
            if ((x&1) == 1) k++;
            x = x >> 1;
        }
        return k;

    }

    public static void main(String[] args) {
        System.out.println(countOne(2147483647));
    }

}
